const router = require('koa-router')()
router.prefix('/topic')
const {
    find,
    findById,
    create,
    update,
    checkTopicExist,
    listTopicFollowers,
    listQuestions
} = require("../controller/topic")
const auth = require("../utils/auth")

// 查询话题列表
router.get("/", find)
// 根据ID查询特定话题
router.post("/create", auth, create)
// 创建一个话题
router.get("/:id", findById)
// 更新一个话题
router.patch("/:id", auth, checkTopicExist, update)
// 获取一个话题的关注者
router.get("/:id/followers", checkTopicExist, listTopicFollowers)

router.get("/:id/questions", checkTopicExist, listQuestions)


module.exports = router